<template>
  <a-drawer
    title="考生成绩修改"
    width=450
    placement="right"
    :closable="false"
    @close="onClose"
    :visible="editVisibile"
    style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
    <a-form :form="form">
      <a-row :gutter="48">
         <a-col :sm="{span:12}" :lg="{span:12}"  >
            <a-form-item label="准考证号">
                <a-input placeholder="请输入..." disabled v-model='postParams.ksbh'/>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:12}"  >
            <a-form-item label="姓名">
                <a-input placeholder="请输入..." disabled v-model='postParams.ksxm'/>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:12}"  >
            <a-form-item label="报考院系">
                <a-input placeholder="请输入..." disabled v-model='postParams.bkyxsmc'/>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:12}"  >
            <a-form-item label="报考专业">
                <a-input placeholder="请输入..." disabled v-model='postParams.bkzymc'/>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:12}"  >
            <a-form-item label="研究方向">
                <a-input placeholder="请输入..." disabled v-model='postParams.bkyjfxmc'/>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:12}"  >
            <a-form-item label="学习形式">
                <a-input placeholder="请输入..." disabled v-model='postParams.zhxlxxxs'/>
            </a-form-item>
          </a-col>
        <a-col ::sm="{span:12}" :lg="{span:12}">
            <a-form-item label="科目一">
              <a-input  v-decorator="[
                    'zzllcj',
                    {
                        rules: [{ required: true, message: '请输入科目一!' }],
                    },
                    {initialValue:postParams.zzllcj}
                    ]"/>
            </a-form-item>
          </a-col>
          <a-col ::sm="{span:12}" :lg="{span:12}">
            <a-form-item label="科目二">
              <a-input  v-decorator="[
                    'wgycj',
                    {
                        rules: [{ required: true, message: '请输入科目二!' }],
                    },
                    {initialValue:postParams.wgycj}
                    ]" />
            </a-form-item>
          </a-col>
          <a-col ::sm="{span:12}" :lg="{span:12}">
            <a-form-item label="科目三">
              <a-input  v-decorator="[
                    'ywkycj',
                    {
                        rules: [{ required: true, message: '请输入科目三!' }],
                    },
                    {initialValue:postParams.ywkycj}
                    ]" />
            </a-form-item>
          </a-col>
          <a-col ::sm="{span:12}" :lg="{span:12}">
            <a-form-item label="科目四">
              <a-input  v-decorator="[
                    'ywkecj',
                    {
                        rules: [{ required: true, message: '请输入科目四!' }],
                    },
                    {initialValue:postParams.ywkecj}
                    ]" />
            </a-form-item>
          </a-col>
          <a-col ::sm="{span:12}" :lg="{span:12}">
            <a-form-item label="总分">
              <a-input  v-decorator="[
                    'cszcj',
                    {
                        rules: [{ required: true, message: '请输入总分!' }],
                    },
                    {initialValue:postParams.cszcj}
                    ]" />
            </a-form-item>
          </a-col>
          <a-col ::sm="{span:12}" :lg="{span:12}">
            <a-form-item label="总分加分">
              <a-input  v-decorator="[
                    'zfjf',
                    {
                        rules: [{ required: true, message: '请输入总分加分!' }],
                    },
                    {initialValue:postParams.zfjf}
                    ]" />
            </a-form-item>
          </a-col>
      </a-row>
    </a-form>
    <div class="drawer-bootom-button">
      <a-button style="margin-right: .8rem" @click="onClose">取消</a-button>
      <a-button @click="handleSubmit" type="primary" :loading="loading">保存</a-button>
    </div>
  </a-drawer>
</template>

<script>
// import moment from 'moment'
import { mapState } from 'vuex'

const formItemLayout = {
  labelCol: { span: 3 },
  wrapperCol: { span: 18 }
}

const selectArr = ['TYPE0126', 'TYPE0075', 'TYPE0125', 'TYPE0072']
export default {
  props: {
    editVisibile: {
      default: false
    },
    info: {
      default: () => ({})
    }
  },
  data () {
    return {
      formItemLayout,
      loading: false,
      postParams: {
      },
      selectMenu: {
       xxlx:[]
      }
    }
  },
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  watch: {
    info (val) {
      this.form.resetFields()
      console.log(this.info)
      for(var item in this.info){
        if(item == 'zzllcj' || item == 'wgycj' || item =='ywkycj' || item =='ywkecj' || item == 'cszcj' ||item == 'zfjf'){
          this.form.getFieldDecorator(item, {initialValue: this.info[item]})
        }
      }
      this.postParams = this.info
      
 
    }
  },
  computed: {
    ...mapState({
      systemInfo: state => state.app.systemInfo,
      TYPE0126: state => state.app['TYPE0126'] // 年级
    })
  },
  created () {
    selectArr.forEach(v => {
      this.$store.dispatch('app/setDictionary', v)
    })
  },
  methods: {
    
    reset () {
      this.postParams = {}
    },
   

    // 关闭
    onClose () {
      this.reset()
      this.$emit('close')
    },
    // 保存
    handleSubmit () {
       this.form.validateFields( (err,values) => {
        if(err){
          this.$message.error("请选择必填项")
        }else{
          var ids ={id:this.postParams.id}
          var params = Object.assign(ids,this.form.getFieldsValue())
          console.log(params)
          this.$api.recruitstat.studentScoreUpdate(params).then(res => {
            this.reset()
            this.$emit('success')
          }).finally(() => {
            this.loadingBtn = false
          })
        }
      })
    }
  }
}
</script>
